package com.ylx.web.p;

import com.ylx.pojo.Goods;
import com.ylx.service.GoodsService;
import com.ylx.service.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/productServlet")
public class ProductServlet extends HttpServlet {

    private GoodsService goodsService = new GoodsServiceImpl();
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {




        List<Goods> goods = goodsService.getProducts();

        request.setAttribute("hotProductList",goods);

        request.getRequestDispatcher("front/index.jsp").forward(request,response);

    }



    protected void doGet (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.doPost(request, response);

    }
}
